#include <iostream>

#include "include/mysql.h"

using namespace std;
const char *server_groups[] = {
  "test2_libmysqld_SERVER", "embedded", "server", NULL
};
int main(int argc, char *argv[])
{
	MYSQL *one;
	mysql_server_init(argc, argv, (char **)server_groups);
	MYSQL *db = mysql_init(NULL);
	mysql_options(db, MYSQL_READ_DEFAULT_GROUP, "test2_libmysqld_CLIENT");
	if (!mysql_real_connect(db, "localhost", "root", "111111", "blog", 0, NULL, 0))
	{
		cout<<"error"<<endl;
	}
	MYSQL_RES   *res;
    MYSQL_ROW    row, end_row;
	
	mysql_list_fields(db, "wp_options", NULL);
	if(res = mysql_store_result(db))
	{
		while ((row = mysql_fetch_row(res)))
		{
			cout<<">>"<<row[0]<<endl;
		}
	}
	exit(0);
	char sqlstr[100];
	cout<<"sql:";
	cin.getline(sqlstr, 100);
	//cout<<sqlstr;
	
	mysql_query(db, sqlstr);
	if(res = mysql_store_result(db))
	{
		int num_fields = mysql_num_fields(res);
		cout<<"num:"<<num_fields<<endl;
		while ((row = mysql_fetch_row(res)))
		{
			cout<<row[0]<<':'<<row[1]<<':'<<row[2]<<endl;
		}
	
	} else {
		cout<<"no"<<endl;
	}
	mysql_free_result(res);
	mysql_close(db);
	
	return 0;
}



